package tableToClass;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;


/**
 * 此工具类为生成JavaBean文件 注意事项： 需要手工设定包名，工程目录，数据库连接字符串等 時間需要使用Timestamp類型
 * 
 * @author 晨曦
 */
public class TableToClass {

	private static final String T = "\t";

	private static final String CRLF = "\r\n";
	
	/**
	 * 是否生成Get对象方法
	 */
	static boolean isGetObj = true;

	// 数据库适配器
	static String driverName = "oracle.jdbc.driver.OracleDriver";

	// URL
	static String url = "jdbc:oracle:thin:@192.168.1.38:1521:orcl";

	static String user = "tjzyy";//qznjwbb_kfk

	static String password = "tjzyy";

	static String database = user; // 数据库名字 

	static String packageName = ""; // 包名
	
	static String author = "HHH";
	
	static String company = "湖南强智科技发展有限公司";

	// 工程目录,目录到达src 后面不要加/
	static String path = "E:\\qznjw\\njwwdb\\src";

	static HashMap map = new HashMap();

	static HashMap<String, String> commMap = new HashMap<String, String>(); // 注释

	// 支持的数据类型，关系到映射
	static HashMap type = new HashMap();
	static {
		type.put("NUMBER", "Double");
		type.put("VARCHAR2", "String");
		type.put("NVARCHAR2", "String");
		type.put("BLOB", "String");
		type.put("CLOB", "String");
		type.put("NVARCHAR2", "String");
		type.put("CHAR", "String");
		type.put("LONG", "Long");
		type.put("Integer", "Integer");
		type.put("BINARY_FLOAT", "Float");
		type.put("BINARY_DOUBLE", "Double");
		type.put("DATE", "Timestamp");
		type.put("INTERVAL DAY(2) TO SECOND(6)", "Timestamp");
		type.put("INTERVAL YEAR(2) TO MONTH", "Timestamp");
		type.put("TIMESTAMP(6) WITH TIME ZONE", "Timestamp");
		type.put("TIMESTAMP(6) WITH LOCAL TIME ZONE", "Timestamp");
		type.put("-1", "String");
	}
	
	/**
	 * 获取从request中取值
	 * @return
	 */
	public static String getRequest(ColumnBean column){
		StringBuffer req = new StringBuffer("");
		String stype = type.get(column.getNumberType()).toString();
		 
		if("Double".equals(stype)){ 
			req.append("request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\") == null ? 0.0 :");
			req.append("Double.parseDouble(request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\"))");
		}else if("Long".equals(stype)){ 
			req.append("request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\") == null ? 0 :");
			req.append("Long.parseLong(request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\"))");
		}else if("Integer".equals(stype)){ 
			req.append("request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\") == null ? 0 :");
			req.append("Integer.parseInteger(request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\"))");
		}else if("Float".equals(stype)){
			req.append("request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\") == null ? 0f :");
			req.append("Float.parseFloat(request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\"))");
		}else if("Timestamp".equals(stype)){ 
			req.append("Timestamp.valueOf(request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\"))");
		}else{
			req.append("request.getParameter(\"");
			req.append(column.getName().toLowerCase());
			req.append("\")");
		}
		return req.toString();
	}
	

	// 构建JavaBean
	private static void createDto(TableBean table,String _strPK) {
		StringBuffer sb = new StringBuffer();
		StringBuffer tostring = new StringBuffer();
		StringBuffer setgetString = new StringBuffer();
		StringBuffer colmnString = new StringBuffer();
		colmnString.append(",");
		sb.append("package ").append(packageName).append(" ;");
		sb.append(CRLF);
		sb.append(CRLF);
		sb.append("import java.sql.Timestamp;");
		sb.append(CRLF);
		sb.append("import java.util.HashMap;");
		sb.append(CRLF);
		sb.append("import java.util.Map;");
		sb.append(CRLF);
		if(isGetObj){
			sb.append("import javax.servlet.http.HttpServletRequest;");
			sb.append(CRLF); 
		}
		sb.append(CRLF);
		sb.append("/**");
		sb.append(CRLF);
		sb.append(" * ");
		sb.append(CRLF);
		sb.append(" * <p>");
		sb.append(CRLF);
		sb.append(" * Title:"+(table.getComment() == null ? "" : table.getComment()));
		sb.append(CRLF);
		sb.append(" * <p>");
		sb.append(CRLF);
		sb.append(" * Description:"+(table.getComment() == null ? "" : table.getComment()));
		sb.append(CRLF);
		sb.append(" * </p>");
		sb.append(CRLF);
		sb.append(" * <p>");
		sb.append(CRLF);
		sb.append(" * Copyright: Copyright (c) 2011");
		sb.append(CRLF);
		sb.append(" * </p>");
		sb.append(CRLF);
		sb.append(" * <p>");
		sb.append(CRLF);
		sb.append(" * Company:").append(company).append(" ");
		sb.append(CRLF);
		sb.append(" * </p>");
		sb.append(CRLF);
		sb.append(" * <p>");
		sb.append(CRLF);
		sb.append(" * Author:").append(author).append(" ");  
		sb.append(CRLF);
		sb.append(" * </p>");
		sb.append(CRLF);
		sb.append(" * Create Time:" + new Date().toLocaleString());
		sb.append(CRLF);
		sb.append("*/");
		sb.append(CRLF);
		String tablename = table.getName();
		String classname = convertT2C(tablename);
		List list = table.getColumns(); 
		sb.append("public class " + classname
				+ " implements java.io.Serializable {");
		sb.append(CRLF);
		sb.append(T);
		sb.append("private static Map strPK= new HashMap();");
		sb.append(CRLF);
		sb.append(CRLF);
		sb.append(T);
		sb.append("public Map getStrPK() {");
		sb.append(CRLF);
		sb.append(CRLF);
		sb.append(T);
		sb.append(T);
		sb.append("return strPK;");
		sb.append(CRLF);
		sb.append(CRLF);
		sb.append(T);
		sb.append("}");
		sb.append(CRLF);
		sb.append(CRLF);
		/**
		 * 取得对象字符串
		 */
		StringBuffer sbGetObj = new StringBuffer(T);
		sbGetObj.append("public static ").append(classname);
		sbGetObj.append(" get").append(classname).append("(HttpServletRequest request) {");
		sbGetObj.append(CRLF).append(T).append(T);
		sbGetObj.append(classname).append(" ").append(classname.toLowerCase());
		sbGetObj.append(" = new ").append(classname).append("();").append(CRLF);
		
		
		for (Iterator iter = list.iterator(); iter.hasNext();) {
			ColumnBean column = (ColumnBean) iter.next(); 
			String columnname = column.getName().toLowerCase();
			colmnString.append(columnname).append(",");
			String stype = type.get(column.getNumberType()).toString();
			
			sbGetObj.append(T).append(T);
			sbGetObj.append(classname.toLowerCase()).append(".").append(getSetter(columnname));
			sbGetObj.append("(").append(getRequest(column)).append(");").append(CRLF);
			
			if (_strPK.toUpperCase().indexOf(columnname.toUpperCase()) != -1) {
				sb.append(T);
				sb.append("static {");
				sb.append(CRLF);
				sb.append(T);
				sb.append(T);
				sb.append("strPK.put(").append("\"").append(columnname)
						.append("\",\"").append(stype).append("\");");
				sb.append(CRLF);
				sb.append(T);
				sb.append("}");
				sb.append(CRLF);
			}
			// 加上注释
			if (commMap.get(columnname) != null
					&& !commMap.get(columnname).equals("")) {
				sb.append(T);
				sb.append("/**");
				sb.append(CRLF);
				sb.append(T);
				sb.append("* ");
				sb.append(commMap.get(columnname).trim()).append("<br>");
				sb.append(CRLF);
				sb.append(T);
				sb.append("* ");
				sb.append("type:");
				sb.append(column.getNumberType());
				sb.append(";Length:");
				sb.append(column.getLength());
				sb.append(CRLF);
				sb.append(T);
				sb.append("*/");
				sb.append(CRLF);
			}

			sb.append(T);
			sb.append("private " + stype + " " + columnname + ";");

			sb.append(CRLF);

			// setter
			setgetString.append(T);
			if (commMap.get(columnname) != null
					&& !commMap.get(columnname).equals("")) {
				setgetString.append("/**").append(CRLF).append(T);
				setgetString.append(" * 设置:").append(commMap.get(columnname) == null ? "" : commMap.get(columnname) ).append(CRLF).append(T);
				setgetString.append(" */").append(CRLF).append(T);
			}
			
			setgetString.append("public void " + getSetter(columnname) + "("
					+ stype + " _" + columnname + ") {");
			setgetString.append(CRLF);

			setgetString.append(T);
			setgetString.append(T);
			setgetString.append("this." + columnname + "=_" + columnname + ";");
			setgetString.append(CRLF);

			setgetString.append(T);
			setgetString.append("}");
			setgetString.append(CRLF);

			setgetString.append(CRLF);
			setgetString.append(CRLF);

			// getter
			setgetString.append(T);
			setgetString.append("/**").append(CRLF).append(T);
			setgetString.append(" * 获取:").append(commMap.get(columnname) ==  null ? "" : commMap.get(columnname)).append(CRLF).append(T);
			setgetString.append(" */").append(CRLF).append(T);
			setgetString.append("public " + stype + " " + getGetter(columnname)
					+ "() {");
			setgetString.append(CRLF);

			setgetString.append(T);
			setgetString.append(T);
			setgetString.append("return " + columnname + ";");
			setgetString.append(CRLF);

			setgetString.append(T);
			setgetString.append("}");
			setgetString.append(CRLF);

			setgetString.append(CRLF);

			//
			tostring.append("\"," + columnname + "=\" + " + columnname + " + ");

		}
		sbGetObj.append(T).append(T).append("return ").append(classname.toLowerCase()).append(";");
		sbGetObj.append(CRLF);
		sbGetObj.append(T).append("}").append(CRLF);
		
		sb.append(CRLF);
		sb.append(setgetString);
		sb.append(CRLF);

		String pv = tostring.toString();
		pv = pv.substring(2);
		// toString
		sb.append(T);
		sb.append("public String toString() {");
		sb.append(CRLF);

		sb.append(T);
		sb.append(T);
		sb.append("return \"" + classname + "[" + pv + "\"]\";");
		sb.append(CRLF);

		sb.append(T);
		sb.append("}");
		sb.append(CRLF);

		sb.append(T);
		sb.append("private String column=\"");
		sb.append(colmnString);
		sb.append("\";");
		sb.append(T);
		sb.append(CRLF);

		sb.append(T);
		sb.append("public String getColumn() {");
		sb.append(CRLF);

		sb.append(T);
		sb.append(T);
		sb.append("return column;");
		sb.append(CRLF);

		sb.append(T);
		sb.append("}");
		sb.append(CRLF);
		if(isGetObj){
			sb.append(sbGetObj);
			sb.append(CRLF);
		}		
		sb.append("}");
		sb.append(CRLF);
		
		
		File dir = new File(path);
		if (!dir.exists()){
			dir.mkdirs();
		}
		

		File file = new File(path + "\\" + classname + ".java");
		try {  
			FileWriter writer = new FileWriter(file);
			writer.write(sb.toString());
			writer.close(); 
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	private static String convertT2C(String tablename) {
		String first = tablename.substring(0, 1).toUpperCase();
		String classname = first + tablename.substring(1).toLowerCase();
		return classname;
	}

	private static String getSetter(String propertyName) {

		String first = propertyName.substring(0, 1).toUpperCase();
		String methodName = "set" + first
				+ propertyName.substring(1).toLowerCase();

		return methodName;
	}

	private static String getGetter(String propertyName) {

		String first = propertyName.substring(0, 1).toUpperCase();
		String methodName = "get" + first
				+ propertyName.substring(1).toLowerCase();

		return methodName;
	}

	/**
	 * 所有的列信息。如下 这里是对应的元数据里的关系，如果想得到某个参数，可以对应获得， TABLE_CAT String => 表类别（可为
	 * null） TABLE_SCHEM String => 表模式（可为 null） TABLE_NAME String => 表名称
	 * COLUMN_NAME String => 列名称 DATA_TYPE int => 来自 java.sql.Types 的 SQL 类型
	 * TYPE_NAME String => 数据源依赖的类型名称，对于 UDT，该类型名称是完全限定的 COLUMN_SIZE int =>
	 * 列的大小。 BUFFER_LENGTH 未被使用。 DECIMAL_DIGITS int => 小数部分的位数。对于 DECIMAL_DIGITS
	 * 不适用的数据类型，则返回 Null。 NUM_PREC_RADIX int => 基数（通常为 10 或 2） NULLABLE int =>
	 * 是否允许使用 NULL。 columnNoNulls - 可能不允许使用 NULL 值 columnNullable - 明确允许使用 NULL
	 * 值 columnNullableUnknown - 不知道是否可使用 null REMARKS String => 描述列的注释（可为 null）
	 * COLUMN_DEF String => 该列的默认值，当值在单引号内时应被解释为一个字符串（可为 null） SQL_DATA_TYPE int
	 * => 未使用 SQL_DATETIME_SUB int => 未使用 CHAR_OCTET_LENGTH int => 对于 char
	 * 类型，该长度是列中的最大字节数 ORDINAL_POSITION int => 表中的列的索引（从 1 开始） IS_NULLABLE
	 * String => ISO 规则用于确定列是否包括 null。 YES --- 如果参数可以包括 NULL NO --- 如果参数不可以包括
	 * NULL 空字符串 --- 如果不知道参数是否可以包括 null SCOPE_CATLOG String =>
	 * 表的类别，它是引用属性的作用域（如果 DATA_TYPE 不是 REF，则为 null） SCOPE_SCHEMA String =>
	 * 表的模式，它是引用属性的作用域（如果 DATA_TYPE 不是 REF，则为 null） SCOPE_TABLE String =>
	 * 表名称，它是引用属性的作用域（如果 DATA_TYPE 不是 REF，则为 null） SOURCE_DATA_TYPE short =>
	 * 不同类型或用户生成 Ref 类型、来自 java.sql.Types 的 SQL 类型的源类型（如果 DATA_TYPE 不是 DISTINCT
	 * 或用户生成的 REF，则为 null） IS_AUTOINCREMENT String => 指示此列是否自动增加 YES ---
	 * 如果该列自动增加 NO --- 如果该列不自动增加 空字符串 --- 如果不能确定该列是否是自动增加参数
	 */

	private static void findTableAndColumn(String _tableName) {

		try {
			Class.forName(driverName);
			Connection conn = DriverManager.getConnection(url, user, password);
			StringBuffer sb1 = new StringBuffer();
			sb1.append("SELECT COLUMN_NAME as NAME, COMMENTS as COMMENTS FROM USER_COL_COMMENTS WHERE TABLE_NAME='")
					.append(_tableName).append("' ");
			Statement stmt = conn.createStatement();
			String sqlTableComm = "select * from User_Tab_Comments tt where tt.table_name = '"+_tableName+"'";
			ResultSet commTb = stmt.executeQuery(sqlTableComm);
			//表注释
			while (commTb.next()) {
				 String tableComment = commTb.getString("COMMENTS");
				 TableBean table = (TableBean) map.get(_tableName);
					if (table == null) {
						table = new TableBean();
						table.setName(_tableName);
						table.setComment(tableComment);
						map.put(_tableName, table);  
					}
			}
			ResultSet commRs = stmt.executeQuery(sb1.toString());
			// 得到字段的注释
			while (commRs.next()) {
				commMap.put(commRs.getString("NAME").toLowerCase(),
						commRs.getString("COMMENTS"));
				
			}
			DatabaseMetaData meta = conn.getMetaData();
			ResultSet rs = meta.getColumns(null, null, _tableName, null);
		 
			System.out.println("------开始------" + _tableName);
			while (rs.next()) {
				if (!rs.getObject(2).equals(database.toUpperCase())) {
					continue;
				}
				String tablename = rs.getString(3);
				TableBean table = (TableBean) map.get(tablename);
				if (table == null) {
					table = new TableBean();
					table.setName(tablename);
					map.put(tablename, table);
				}

				ColumnBean column = new ColumnBean();
				column.setName(rs.getString(4));
				column.setType(rs.getInt(5));
				column.setNumberType(rs.getString(6));
				
				System.out.println("字段名称:" + rs.getString(4));
				System.out.println("数据库类型判定" + rs.getInt(5));
				System.out.println("1:" + rs.getObject(1));
				System.out.println("2:" + rs.getObject(2));

				System.out.println("6:" + rs.getObject(6));
				System.out.println("7长度:" + rs.getObject(7));
				System.out.println("8小数点：" + rs.getString("DECIMAL_DIGITS"));
				
				column.setLength(rs.getInt(7));
				String sumLength = rs.getString("DECIMAL_DIGITS");
				// 如果是number类型，并且木小数点的情况那么使用int类型

				if (rs.getObject(6).equals("NUMBER")
						&& (sumLength == null || sumLength.equals("0"))) {
					column.setNumberType("Integer");
				}
				table.getColumns().add(column);
			}
			System.out.println("------结束------"+ _tableName);
			rs.close();
			commTb.close();
			conn.close();

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}

	}

	/**
	 * 获取主键
	 */
	private static String getPK(String _tableName) {
		try {
			Class.forName(driverName);
			Connection conn = DriverManager.getConnection(url, user, password);
			Statement stmt = conn.createStatement();
			DatabaseMetaData dbMeta = conn.getMetaData();
			ResultSet pkRSet = dbMeta.getPrimaryKeys(null, null, _tableName);
			String PK = "";
			while (pkRSet.next()) {
				if (!pkRSet.getObject(2).equals(database.toUpperCase())) {
					continue;
				}
				if (pkRSet.getObject(6) == null
						|| pkRSet.getObject(6).equals("")) {
					throw new RuntimeException("请设置主键");
				}
				PK = (String) pkRSet.getObject(6);
				break;

			}
			StringBuffer sb = new StringBuffer();
			sb.append(
					"select COLUMN_NAME as name from user_cons_columns T where T.TABLE_NAME='")
					.append(_tableName).append("' ");
			sb.append(" and T.CONSTRAINT_NAME= '").append(PK).append("' ");
			ResultSet rs = stmt.executeQuery(sb.toString());
			StringBuffer sb1 = new StringBuffer();
			while (rs.next()) {
				sb1.append(((String) rs.getObject("name")).toLowerCase())
						.append(",");

			}
			rs.close();
			stmt.close();
			conn.close();
			String pkid = sb1.toString();
			if (pkid != null && !pkid.equals("") && pkid.length() > 1)
				pkid = pkid.substring(0, pkid.length() - 1);
			return pkid;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}
		return null;
	}

	/**
	 * 测试
	 * 
	 */
	private static void testmeta() {

		// String sql = "select * from cuser ";

		try {
			Class.forName(driverName);
			Connection conn = DriverManager.getConnection(url, user, password);

			DatabaseMetaData meta = conn.getMetaData();
			ResultSet rs = meta.getColumns(null, null, "c%", null);

			while (rs.next()) {
				print(rs);
				System.out.println();
			}

			conn.close();

		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}
	}

	private static void print(ResultSet rs) {

		try {
			int count = rs.getMetaData().getColumnCount();
			for (int i = 0; i < count; i++) {
				System.out.print(rs.getString(1 + i));
				System.out.print("\t");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}

	}

	// 測試方法
	private static void testODBC(String _tableName) {

		String sql = "select * from userdto ";

		try {
			Class.forName(driverName);
			Connection conn = DriverManager.getConnection(url, user, password);
			Statement stmt = conn.createStatement();
			DatabaseMetaData dbMeta = conn.getMetaData();
			ResultSet pkRSet = dbMeta.getPrimaryKeys(null, null, _tableName);
			while (pkRSet.next()) {
				System.err.println("****** Table  ******");
				System.err.println("TABLE_CAT : " + pkRSet.getObject(1));
				System.err.println("TABLE_SCHEM: " + pkRSet.getObject(2));
				System.err.println("TABLE_NAME : " + pkRSet.getObject(3));
				System.err.println("COLUMN_NAME: " + pkRSet.getObject(4));
				System.err.println("KEY_SEQ : " + pkRSet.getObject(5));
				System.err.println("PK_NAME : " + pkRSet.getObject(6));
				if (pkRSet.getObject(6) == null
						|| pkRSet.getObject(6).equals("")) {
					throw new RuntimeException("请设置主键");
				}
				StringBuffer sb = new StringBuffer();
				sb.append(
						"select COLUMN_NAME as name from user_cons_columns T where T.TABLE_NAME='")
						.append(_tableName).append("' ");
				sb.append(" and T.CONSTRAINT_NAME= '")
						.append(pkRSet.getObject(6)).append("' ");
				System.out.println("比" + sb.toString());
				System.out.println("靠");
				ResultSet rs = stmt.executeQuery(sb.toString());
				while (rs.next()) {
					System.out.println("ririririri8riri日日："
							+ rs.getObject("name"));
				}
				System.err.println("****** ******* ******");
				rs.close();
			}
			stmt.close();
			conn.close();
			System.out.println("success");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}
	}

	// 解析包名，然后设置下级目录
	private static void getpath() {
		if (packageName != null && !packageName.equals("")) {
			String[] s = packageName.split("\\.");
			StringBuffer sb = new StringBuffer();
			sb.append(path);
			sb.append("/");
			for (String str : s) {
				sb.append(str).append("/");
			}
			path = sb.toString();
			// 如果没有该目录，就创建该目录
			File file = new File(path);
			if (!file.isDirectory()) {
				file.mkdirs();
			}
		}
	}

	private static void print(List list) {
		for (Iterator iter = list.iterator(); iter.hasNext();) {
			System.out.println(iter.next());
		}

	}
	
	
	public static void main(String[] args) {
		//tableName = "ZzdJcjfyy".toUpperCase();
		// testODBC();
		// 下面3个参数，需要手工输入到src
		isGetObj = false;
		path =  "E:\\Workspaces\\MyEclipse 10\\bjlydx_my\\src";
		packageName = "com.qzdatasoft";
		String tableName = "xs0701";
		String strPK = "xs0701id";
		 	
		// 开始执行
		String [] tableNames = tableName.split(",");
		getpath();
		if(tableNames.length > 0){
			for(int i = 0; i < tableNames.length; i++){
				
				tableName = tableNames[i].toUpperCase();
				System.out.println("tableName:"+tableName);
				strPK = getPK(tableName.toUpperCase());
				System.out.println("PK :"+ strPK);
				findTableAndColumn(tableName);
				
			}
			Set set = map.entrySet();
			for (Iterator iter = set.iterator(); iter.hasNext();) {
				Entry element = (Entry) iter.next();
				TableBean table = (TableBean) element.getValue();
				strPK = getPK(table.getName().toUpperCase());
				createDto(table,strPK);
			}
		}else{
			tableName = tableName.toUpperCase();
			strPK = getPK(tableName);
			getpath();
			findTableAndColumn(tableName);
			Set set = map.entrySet();
			for (Iterator iter = set.iterator(); iter.hasNext();) {
				Entry element = (Entry) iter.next();
				TableBean table = (TableBean) element.getValue();
				createDto(table,strPK);
			}
		}
		
		System.out.println("success !!");
		
	 
	}
}
